from typing import *
from leetcode.editor.common.node import *


# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def longestPalindrome(self, s: str) -> str:
        longstr = ""
        for i in range(len(s)):
            s1 = self.returnLongest(i, i, s)
            s2 = self.returnLongest(i, i + 1, s)
            longstr = s1 if len(s1) > len(longstr) else longstr
            longstr = s2 if len(s2) > len(longstr) else longstr
        return longstr

    def returnLongest(self, l, r, s):
        while l >= 0 and r < len(s) and s[l] == s[r]:
            l -= 1
            r += 1
        return s[l + 1:r]
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    # your test code here